#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int my_atoi(const char* p)
{
	while (isspace(*p))
		p++;
	int flag = 1;
	int add = 0;
	int n = 0;
	if (*p == '+')
	{
		flag = 1;
		p++;
	}
	else if (*p == '-')
	{
		flag = -1;
		p++;
	}
	while (*p != '\0')
	{
		if (isdigit(*p))
		{
			n = *p - '0';
			add = add * 10 + n;
			p++;
		}
		else
			break;
	}
	return flag * add;
}

int main()
{
	printf("%d\n", my_atoi(" "));
	printf("%d\n", my_atoi("	abc"));
	printf("%d\n", my_atoi("123"));
	printf("%d\n", my_atoi("		123"));
	printf("%d\n", my_atoi("		+123"));
	printf("%d\n", my_atoi("		-123"));
	printf("%d\n", my_atoi("		-123abc"));
	return 0;
}